package fiuba.algo3.vista;

import java.awt.Color;

import javax.swing.*;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

@SuppressWarnings("serial")
public class WCartelDeAlerta extends JWindow implements ActionListener{
	
	private static int maxWidth = GetScreenWorkingWidth();
	private static int maxHeight = GetScreenWorkingHeight();
	
	private JLabel mensaje;
	private JButton aceptar;
	
	private JFPrincipal principal;
	
	
	public WCartelDeAlerta(String mensajeAMostrar,JFPrincipal principal){
		this.principal = principal;
		
		this.setBounds((maxWidth-210)/2,(maxHeight-210)/2,210,210);
		this.getContentPane().setBackground(Color.lightGray);
		this.setVisible(true);
		

		aceptar = new JButton ("Aceptar");
		aceptar.setBounds(55,120,100,40);
		aceptar.addActionListener(this);
		aceptar.setVisible(true);
		this.add(aceptar);		
		
		mensaje = new JLabel(mensajeAMostrar);
		mensaje.setBounds(35,50,140,40);
		mensaje.setBackground(Color.blue);
		mensaje.setVisible(true);
		this.add(mensaje);
		
		JDesktopPane fondo = new JDesktopPane();
		fondo.setOpaque(false);
		this.add(fondo);
		
		
	}
	
	private static int GetScreenWorkingWidth(){
	    return java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().width;
	}

	private static int GetScreenWorkingHeight(){
	    return java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds().height;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
	    if (e.getSource()== aceptar){
	    	this.principal.quitarMenus();
	    	this.setVisible(false);
	    }
	}

}
